package leetcode;

/**
 * @program: datastructureandalogorithm
 * @description:
 * @author: hmx
 * @create: 2022-01-07 00:08
 **/
public class LeetCode1614 {

    public int maxDepth(String s) {
        int n = s.length();
        int res = 0;
        int level = 0;
        for (int i = 0; i < n; i++) {
            char c = s.charAt(i);
            if (c == '(') {
                ++level;
                res = Math.max(res, level);
            } else if (c == ')') {
                --level;
            }
        }

        return res;
    }

}
